package com.ihr360.alps.api;

import com.ihr360.commons.data.util.Pair;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
public interface IServiceProvider<T> {

    /**
     * 获取公司下某个服务所有记录
     *
     * @return
     */
    @GetMapping( produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    default Map<String,T> getItems(@RequestParam(name = "companyId") String companyId){
        return null;
    }

    /**
     * 获取公司下某个服务某条记录
     *
     * @param id
     * @param companyId
     * @return
     */
    @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    default Pair<String,T> getItem(@PathVariable(name = "id") String id, @RequestParam(name = "companyId") String companyId){
        return null;
    }

    /**
     * 根据公司id和员工id列表获取一组数据
     *
     * @return
     */
    @PostMapping( produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
     default Map<String,T> getItems(@RequestParam(name = "companyId") String companyId,
                                             @RequestBody IDListRequest<String> idListRequest){
        return null;
    }


    /**
     * 根据公司id和员工id列表和年月信息获取一组数据
     *
     * @return
     */
    @PostMapping(value = "/{year}/{month}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    default Map<String,T> getItems(@RequestParam(name = "companyId") String companyId,
                                             @PathVariable(name = "year") int year,
                                             @PathVariable(name = "month") int month,
                                             @RequestBody IDListWithCriteriaRequest<String> request){
        return null;
    }


    /**
     * 根据公司id和员工id列表和其他查询条件获取一组数据(最复杂的应用场景)
     *
     * @return
     */
    @PostMapping(value = "/search", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    default Map<String,T> getItemsByCriteria(@RequestParam(name = "companyId") String companyId,
                                                       @RequestBody IDListWithCriteriaRequest<String> request){
        return null;
    }

}